package com.example.book_recommend.service.impl;

import com.example.book_recommend.dao.PrivilegeMapper;
import com.example.book_recommend.dao.RolePrivilegeMapper;
import com.example.book_recommend.entity.Privilege;
import com.example.book_recommend.entity.RolePrivilege;
import com.example.book_recommend.entity.RolePrivilegeKey;
import com.example.book_recommend.service.RolePrivilegeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RolePrivilegeServiceImpl implements RolePrivilegeService {
    @Autowired
    PrivilegeMapper privilegeMapper;

    @Autowired
    RolePrivilegeMapper rolePrivilegeMapper;

    @Override
    public Integer[] getPrivilegesByRole(Integer roleId) {

        return rolePrivilegeMapper.getPrivilegesByRoleId(roleId);
    }

    @Override
    public Integer[] getPrivilegesByRole0(Integer roleId) {
        return new Integer[0];
    }

    @Override
    public int delete(RolePrivilegeKey rolePrivilegeKey) {
        return rolePrivilegeMapper.deleteByPrimaryKey(rolePrivilegeKey);
    }

    @Override
    public int deleteByRole(Integer roleId) {
        return rolePrivilegeMapper.deleteByRole(roleId);
    }
}
